package c2.group.business.gradepvp;

import c2.group.business.base.GroupSubModule;
import cate.game.pvp.gradepvp.GradePvpMsg;
import cate.game.pvp.gradepvp.dto.GradePvpFightOverParam;
import cate.game.pvp.gradepvp.dto.GradePvpMatchParam;
import cate.game.pvp.gradepvp.dto.GradePvpPlayerData;
import cate.game.role.RoleSimpleBase;
import cate.game.role.pvp.gradepvp.GradePvpRecord;

import java.util.List;

public class GradePvpRecvModule extends GroupSubModule<GradePvpModule> {
    @Override
    public void initDependent() {
        useRpcRecv().onRequestResponseTemplate(GradePvpMsg.MATCH_REQ, GradePvpMatchParam.class,
                (h, req) -> this.match(req));
        useRpcRecv().onFireAndForgetTemplate(GradePvpMsg.FIGHT_OVER, GradePvpFightOverParam.class,
                (h, req) -> this.fightOver(req));
        useRpcRecv().onRequestResponseTemplate(GradePvpMsg.SIX_GOD, Integer.class,
                (h, req) -> this.loadSixGod(req));
        useRpcRecv().onRequestResponseTemplate(GradePvpMsg.NEW_BEE_RECORDS, Void.class,
                (h, req) -> this.loadNewBeeRecords());
        useRpcRecv().onRequestResponseTemplate(GradePvpMsg.MY_RANK, String.class,
                (h, req) -> this.loadMyRank(req));
    }

    private GradePvpPlayerData match(GradePvpMatchParam req) {
        return parent.match(req.playerUid, req.star);
    }

    private void fightOver(GradePvpFightOverParam req) {
        parent.fightOver(req.a, req.star, req.score, req.record);
    }

    private List<RoleSimpleBase> loadSixGod(int season) {
        return parent.loadSixGod(season);
    }

    private List<GradePvpRecord> loadNewBeeRecords() {
        return parent.loadNewBeeRecords();
    }

    private int loadMyRank(String roleUid) {
        return parent.loadMyRank(roleUid);
    }
}
